﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using VPC.BO;
using VPC.BL;

namespace VPC.UI
{
    public partial class AdvancedSearchForm : Form
    {
        public AdvancedSearchForm()
        {
            InitializeComponent();
        }

        // Load search result in the DataGridView Control
        public void AdvancedSearchForm_Load()
        {
            string sFName = textBoxFirstName.Text;
            List<ContactBO> lstContactDetails = new List<ContactBO>();

            lstContactDetails = ContactBL.GetContactDetails(sFName);

            dataGridViewContactDetails.DataSource = lstContactDetails;
        }

        //When the user double clicks on a contact, the Welcome Form is displayed with the Contact Details
        private void dataGridViewContactDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string sContactId = dataGridViewContactDetails.SelectedCells[0].Value.ToString();
            WelcomeForm frmWF = new WelcomeForm();
            frmWF.textBoxContactId.Text = sContactId;
            this.Hide();
            frmWF.showData();
            frmWF.ShowDialog();
        }

    }
}